package com.zh.blog.exception;

import com.zh.blog.common.api.StatusCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import static com.zh.blog.common.api.StatusCodeEnum.FAILED;

/**
 * 用户名异常处理类
 * @author ZhengHao
 * Created At 2022/7/30.
 **/
@Getter
@AllArgsConstructor
public class BizException extends RuntimeException{
    /**
     * 错误码
     */
    private Integer code = FAILED.getCode();

    /**
     * 错误信息
     */
    private final String message;

    public BizException(String message){
        this.message = message;
    }

    public BizException(StatusCodeEnum statusCodeEnum){
        this.code = statusCodeEnum.getCode();
        this.message = statusCodeEnum.getDesc();
    }
}